<%@page import="java.util.Date"%>
<%@page import="com.smfx.yxt.utils.DateUtil"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path;
	String currDate = DateUtil.dateToStr(new Date(), DateUtil.DEFAULT_DATE_FORMAT3);
	String lastDate = DateUtil.getLastDate(1);
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<title>教师报名列表-云校通</title>
<jsp:include page="/WEB-INF/page/common/_header.jsp"></jsp:include>
<script src="<%=basePath %>/js/picker.js"></script>
<body ontouchstart style="background-color: #f8f8f8;">
    <div class="page-bd">
      <ul>
        <li class="">
            <div class="weui-flex js-category">
                <p class="weui-flex-item center" style="text-align: center;">快速查询</p>
                <i class="icon icon-74"></i>
            </div>
            <div class="page-category js-categoryInner">
              <div class="weui_cells weui_cells_access" style="margin-top: 0px;">
                <a class="weui_cell" href="javascript:;">
                  	<div class="weui_cell_bd weui_cell_primary">
                      <input class="weui_input" type="text" value="<%=lastDate %>" id='startDate'/>
                    </div>
                    <div class="weui_cell_bd mr20">到</div>
                    <div class="weui_cell_bd weui_cell_primary">
                      <input class="weui_input right" type="text" value="<%=currDate %>" id='endDate'/>    
                    </div>
                    <div class="weui_cell_bd" id="search" style="text-align: right; padding: 2px 10px;background: #efefef; border-radius: 5px; color: #18b4ed;">
                    	查询
                    </div>
                </a>   
              </div>
            </div>
        </li>
      </ul>
    </div>

    <div class="weui_panel weui_panel_access layout" style="margin-top:-5px;">
        <div class="weui_panel_bd">
            <div class="weui_media_box weui_media_small_appmsg">
	            <div class="weui_cells weui_cells_access" id="teacher">
	             	
	            </div>
	            <div class="dropload-down">
				    <div class="loadData dropload-hasData">点击加载更多数据...</div>
				</div>
            </div>
        </div>
    </div>       
    <jsp:include page="/WEB-INF/page/common/_footer.jsp"></jsp:include>
</body>
<script>
	  var page = 1, rows = 5;
      $(function(){
	    	getData();
	    	$("#search").click(function() {
	    		page = 1; 
	    		rows = 5;
				$('.loadData').removeClass("dropload-noData").addClass("dropload-hasData").html("点击加载更多数据...");
				$("#teacher").html("");
				getData();
	    	})
	        $('.js-category').click(function(){
		          $parent = $(this).parent('li');
		           if($parent.hasClass('js-show')){
		              $parent.removeClass('js-show');
		              $(this).children('i').removeClass('icon-35').addClass('icon-74');
		          }else{
		              $parent.siblings().removeClass('js-show');
		              $parent.addClass('js-show');
		              $(this).children('i').removeClass('icon-74').addClass('icon-35');
		               $parent.siblings().find('i').removeClass('icon-35').addClass('icon-74');
		          }
	        });
	        $("#startDate").datetimePicker({title:"选择日期",m:1});
	        $("#endDate").datetimePicker({title:"选择日期",m:1});
	        $(".dropload-down").on("click", ".dropload-hasData", function() {
	        	getData();
			});
       });    
       
    	//从服务器获取json ,status 首次页面加载1，追加数据 2 
		function getData(){
			$.ajax({
				type:"post",
				url:"<%=basePath%>/ls/signUp/teacher/page/query",
				data:{
					page: page,
					rows: rows,
					startDate: $("#startDate").val(),
					endDate: $("#endDate").val()
				},
				dataType:"json",
				success:function(data){
					if(data.code == '000') {
						page+=1;
						var temp = data.data.rows;
						if(temp.length == 0 || page*rows >= data.data.total) {// 如果没有数据
		            		 $('.loadData').removeClass("dropload-hasData").addClass("dropload-noData").html("没有更多数据了");
		                }
					    addData(temp);
					}
				}
			});
		}
    	
		//status != 1时追加内容
		function addData(data) {
			var id = "#teacher";
			var html = "";
			for (var i = 0; i < data.length; i++) {
				html += '<a class="weui_cell" href="<%=basePath%>/ls/signUp/teacher/detail?id='+data[i].id+'">\
                <div class="weui_cell_bd weui_cell_primary">\
					<h4 class="weui_media_title f-blue" style="white-space: inherit;">'+data[i].name+'</h4>\
					<p class="weui_media_desc mt10">应聘岗位：'+data[i].position+'</p>\
					<p class="weui_media_desc mt5">应聘时间：'+getTime(data[i].signUpTime,"yyyy-MM-dd hh:mm")+'</p>\
	   			   </div>\
	   			   <span class="weui_cell_ft"></span>\
				</a>';
			}
			$(id).append(html);
		};
</script>
</html>